<?php

	$TEMP->set_file(array('handle' => DIR_IFRAME_VIEW . 'forgotPasswordRequest.html'));
	
	if ( isset($_POST['subButton']) ) {
		
		$if_error		= 0;
		$if_display		= 0;
		$txtstudno		= _POST('txtstudno');
		$txtfname		= _POST('txtfname');
		$txtmname		= _POST('txtmname');
		$txtlname		= _POST('txtlname');
		$txtemail		= _POST('txtemail'); 
		$txtmessage		= _POST('txtmessage');
		
		if ( empty($txtstudno) )	{ $if_error++; $_txtstudno 		= REQ_FIELD; }
		if ( empty($txtfname) )		{ $if_error++; $_txtfname 		= REQ_FIELD; }
		if ( empty($txtmname) )		{ $if_error++; $_txtmname 		= REQ_FIELD; }
		if ( empty($txtlname) )		{ $if_error++; $_txtlname 		= REQ_FIELD; }
		if ( empty($txtemail) )		{ $if_error++; $_txtemail 		= REQ_FIELD; }
		else {
			$emailReturn = $EMAIL->validateEmail($txtemail);
			if ($emailReturn === TRUE) {
				 $if_error++;
				$_txtemail 	= INVALID_EMAIL;
			}
		}
		if ( empty($txtmessage) )		{ $if_error++; $_txtmessage = REQ_FIELD; }
		
		
		if ( $if_error == 0 ) {
			$strArray = array('stud_no' 	=> upperCase($txtstudno),
							  'first_name' 	=> firstUpperCase($txtfname),
							  'last_name' 	=> firstUpperCase($txtlname),
							  'middle_name' => firstUpperCase($txtmname),
							  'email' 		=> $txtemail,
							  'message' 	=> $txtmessage,
							  'type' 		=> 'password');
			$STUD->insertStudentRequest($strArray);
			$saved_record = 1;
		}
	}
	
	$TEMP->set_var(array('txtstudno' 		=> $txtstudno,
						 'txtfname'			=> $txtfname,
						 'txtmname' 		=> $txtmname,
						 'txtlname' 		=> $txtlname,
						 'txtemail' 		=> $txtemail,
						 'txtmessage'		=> $txtmessage,
						 
						 'w_txtstudno' 		=> $_txtstudno,
						 'w_txtfname' 		=> $_txtfname,
						 'w_txtmname' 		=> $_txtmname,
						 'w_txtlname' 		=> $_txtlname,
						 'w_txtemail' 		=> $_txtemail,
						 'w_txtmessage'		=> $_txtmessage,
						 
						 'saved_record'		=> $saved_record,
						 ));
?>